HAL HRTIM callbacks irq and Callbacks functions

This section provides information about the HAL HRTIM callbacks register/unregister functions migration.

Callback for burst DMA transfer completion.

HAL1

HAL2

void HAL_HRTIM_BurstDMATransferCallback(HRTIM_HandleTypeDef *hhrtim,
                                        uint32_t TimerIdx);
void HAL_HRTIM_DMACpltCallback(hal_hrtim_handle_t *hhrtim,
                               uint32_t timer);

Callback for burst mode period event.

HAL1

HAL2

void HAL_HRTIM_BurstModePeriodCallback(HRTIM_HandleTypeDef *hhrtim);
void HAL_HRTIM_BurstModePeriodCallback(hal_hrtim_handle_t *hhrtim);

Callback for capture event.

HAL1

HAL2

  • Capture 1 Callback

void HAL_HRTIM_Capture1EventCallback(HRTIM_HandleTypeDef *hhrtim,
                                     uint32_t TimerIdx);
  • Capture 2 Callback

void HAL_HRTIM_Capture2EventCallback(HRTIM_HandleTypeDef *hhrtim,
                                     uint32_t TimerIdx);
  • In HAL1, separate callbacks were provided for each capture unit.

  • In HAL2, these callbacks are unified into one callback function that includes a parameter indicating the capture unit.

void HAL_HRTIM_CaptureCallback(hal_hrtim_handle_t *hhrtim,
                               uint32_t timer,
                               hal_hrtim_capture_unit_t capture_unit);

Callback for compare event.

HAL1

HAL2

  • Compare 1 event Callback

void HAL_HRTIM_Compare1EventCallback(HRTIM_HandleTypeDef *hhrtim,
                                     uint32_t TimerIdx);
  • Compare 2 event Callback

void HAL_HRTIM_Compare2EventCallback(HRTIM_HandleTypeDef *hhrtim,
                                     uint32_t TimerIdx);
  • Compare 3 event Callback

void HAL_HRTIM_Compare3EventCallback(HRTIM_HandleTypeDef *hhrtim,
                                     uint32_t TimerIdx);
  • Compare 4 event Callback

void HAL_HRTIM_Compare4EventCallback(HRTIM_HandleTypeDef *hhrtim,
                                     uint32_t TimerIdx);
  • In HAL1, separate callbacks were provided for each compare unit.

  • In HAL2, these callbacks are unified into one callback function that includes a parameter indicating the compare unit.

void HAL_HRTIM_CompareMatchCallback(hal_hrtim_handle_t *hhrtim,
                                    uint32_t timer,
                                    hal_hrtim_compare_unit_t compare_unit);

Callback for counter reset event.

HAL1

HAL2

void HAL_HRTIM_CounterResetCallback(HRTIM_HandleTypeDef *hhrtim,
                                    uint32_t TimerIdx);
void HAL_HRTIM_ResetCallback(hal_hrtim_handle_t *hhrtim,
                             uint32_t timer);

Callback when DLL calibration is ready.

HAL1

HAL2

void HAL_HRTIM_DLLCalibrationReadyCallback(HRTIM_HandleTypeDef *hhrtim);
void HAL_HRTIM_DLLCalibrationCallback(hal_hrtim_handle_t *hhrtim);

Callback for delayed protection event.

HAL1

HAL2

void HAL_HRTIM_DelayedProtectionCallback(HRTIM_HandleTypeDef *hhrtim,
                                         uint32_t TimerIdx);
void HAL_HRTIM_DelayedProtectionCallback(hal_hrtim_handle_t *hhrtim,
                                         uint32_t timer);

Callback for HRTIM error.

HAL1

HAL2

void HAL_HRTIM_ErrorCallback(HRTIM_HandleTypeDef *hhrtim);
void HAL_HRTIM_DMAErrorCallback(hal_hrtim_handle_t *hhrtim,
                                uint32_t timer);

Callback for fault event.

HAL1

HAL2

  • Fault 1 event Callback

void HAL_HRTIM_Fault1Callback(HRTIM_HandleTypeDef *hhrtim);
  • Fault 2 event Callback

void HAL_HRTIM_Fault2Callback(HRTIM_HandleTypeDef *hhrtim);
  • Fault 3 event Callback

void HAL_HRTIM_Fault3Callback(HRTIM_HandleTypeDef *hhrtim);
  • Fault 4 event Callback

void HAL_HRTIM_Fault4Callback(HRTIM_HandleTypeDef *hhrtim);
  • Fault 5 event Callback

void HAL_HRTIM_Fault5Callback(HRTIM_HandleTypeDef *hhrtim);
  • Fault 6 event Callback

void HAL_HRTIM_Fault6Callback(HRTIM_HandleTypeDef *hhrtim);
  • In HAL1, we have individual callbacks for each fault event.

  • In HAL2, these callbacks are consolidated into a single callback function that receives the fault identifier as a parameter.

void HAL_HRTIM_FaultCallback(hal_hrtim_handle_t *hhrtim,
                              uint32_t fault);

Callback for output reset event.

HAL1

HAL2

  • Output 1 Reset event Callback

void HAL_HRTIM_Output1ResetCallback(HRTIM_HandleTypeDef *hhrtim,
                        uint32_t TimerIdx);
  • Output 2 Reset event Callback

void HAL_HRTIM_Output2ResetCallback(HRTIM_HandleTypeDef *hhrtim,
                        uint32_t TimerIdx);
  • In HAL1, separate callbacks were provided for each output reset event.

  • In HAL2, these callbacks are unified into one callback function that includes a parameter indicating the output.

void HAL_HRTIM_OutputResetCallback(hal_hrtim_handle_t *hhrtim,
                       uint32_t output);

Callback for output set event.

HAL1

HAL2

  • In HAL1, separate callbacks were provided for each output set event.

void HAL_HRTIM_Output1SetCallback(HRTIM_HandleTypeDef *hhrtim,
                      uint32_t TimerIdx);
void HAL_HRTIM_Output2SetCallback(HRTIM_HandleTypeDef *hhrtim,
                      uint32_t TimerIdx);
  • In HAL2, these callbacks are unified into one callback function that includes a parameter indicating the output.

void HAL_HRTIM_OutputSetCallback(hal_hrtim_handle_t *hhrtim,
                      uint32_t output);

Callback for repetition event.

HAL1

HAL2

void HAL_HRTIM_RepetitionEventCallback(HRTIM_HandleTypeDef *hhrtim,
                                       uint32_t TimerIdx);
void HAL_HRTIM_RepetitionCallback(hal_hrtim_handle_t *hhrtim,
                                  uint32_t timer);

Callback for update event.

HAL1

HAL2

void HAL_HRTIM_RegistersUpdateCallback(HRTIM_HandleTypeDef *hhrtim,
                                       uint32_t TimerIdx);
void HAL_HRTIM_UpdateCallback(hal_hrtim_handle_t *hhrtim,
                              uint32_t timer);

Callback for synchronization event.

HAL1

HAL2

void HAL_HRTIM_SynchronizationEventCallback(HRTIM_HandleTypeDef *hhrtim);
void HAL_HRTIM_SynchroCallback(hal_hrtim_handle_t *hhrtim);

Callback for system fault event.

HAL1

HAL2

void HAL_HRTIM_SystemFaultCallback(HRTIM_HandleTypeDef *hhrtim);
void HAL_HRTIM_SystemFaultCallback(hal_hrtim_handle_t *hhrtim);

HAL HRTIM Register Callbacks functions

HAL1

HAL2

In HAL1, the function HAL_HRTIM_RegisterCallback and HAL_HRTIM_TIMxRegisterCallback are used to register HRTIM and HRTIM Timer x callbacks using a single function with a specific callback ID.

In HAL2, separate functions are available to register each specific callback, providing more granularity and control over the callback registration process.

For example

HAL_HRTIM_RegisterCallback(&HRTIM_HANDLE,
                           HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID,
                           USER_HRTIM_SystemFaultCallback);

HAL_HRTIM_TIMxRegisterCallback(&HRTIM_HANDLE,
                               HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID,
                               USER_HRTIM_TIM_Output1SetCallback)
HAL_HRTIM_RegisterSystemFaultCallback(&HRTIM_HANDLE,
                                      USER_HRTIM_SystemFaultCallback);



HAL_HRTIM_RegisterOutputSetCallback(&HRTIM_HANDLE,
                                    USER_HRTIM_TIM_Output1SetCallback);

HAL HRTIM and TIMER UnRegister Callbacks functions

HAL1

HAL2

In HAL1, the functions HAL_HRTIM_UnRegisterCallback and HAL_HRTIM_TIMxUnRegisterCallback are used to unregister HRTIM and HRTIM Timer x callbacks, respectively. Both functions accept a specific callback ID to identify which callback to unregister.

In HAL2, the unregister callback API has been removed. Instead, callbacks can be managed by re-registering the default HAL HRTIM weak callbacks as needed.

For example

HAL_HRTIM_UnRegisterCallback(&HRTIM_HANDLE,
                             HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID);

HAL_HRTIM_TIMxUnRegisterCallback(&HRTIM_HANDLE,
                                 HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID)
HAL_HRTIM_RegisterSystemFaultCallback(&HRTIM_HANDLE,
                                      HAL_HRTIM_SystemFaultCallback);



HAL_HRTIM_RegisterOutputSetCallback(&HRTIM_HANDLE,
                                    HAL_HRTIM_OutputSetCallback);

HAL HRTIM IRQ Handler

HAL1

HAL2

In HAL1, a single IRQ handler function is used for all HRTIM interrupts, with the specific timer identified by a parameter.

In HAL2, dedicated IRQ handler functions are provided for each HRTIM timer and fault event.

void HAL_HRTIM_IRQHandler(HRTIM_HandleTypeDef *hhrtim,
                         uint32_t TimerIdx);
void HAL_HRTIM_M_IRQHandler(hal_hrtim_handle_t *hhrtim);
void HAL_HRTIM_TIMA_IRQHandler(hal_hrtim_handle_t *hhrtim);
void HAL_HRTIM_TIMB_IRQHandler(hal_hrtim_handle_t *hhrtim);
void HAL_HRTIM_TIMC_IRQHandler(hal_hrtim_handle_t *hhrtim);
void HAL_HRTIM_TIMD_IRQHandler(hal_hrtim_handle_t *hhrtim);
void HAL_HRTIM_TIME_IRQHandler(hal_hrtim_handle_t *hhrtim);
void HAL_HRTIM_TIMF_IRQHandler(hal_hrtim_handle_t *hhrtim);
void HAL_HRTIM_FLT_IRQHandler(hal_hrtim_handle_t *hhrtim);

Related concept: